import Tip from '@/util/tip.js';

const install = function(vue) {
	vue.prototype.$tip = Tip;
	vue.prototype.$adpid = "1111111111"
	vue.prototype.$checkPermission = function(permission){
		let data = uni.getStorageSync("userInfo");
		if(data){
			let arr = [];
			if(Array.isArray(permission)){
				permission.forEach(t=>{
					let tArr = data.roles.filter(item=>item.roleKey==t)||[];
					arr=arr.concat(tArr);
				})
			}else{
				 arr = data.roles.filter(item=>item.roleKey==permission);
			}

			return arr&&arr.length>0;
		}else{
			console.error("用户未登录")
		}
		return false;
	}
}

export default install;
